package com.itheima05;

import java.util.ArrayList;
import java.util.function.Predicate;

public class PredicateTest {
    public static void main(String[] args) {

        String[] strArray = {"张三三,30", "柳岩,34", "张曼玉,35", "貂蝉,31", "林祖先,33"};
        ArrayList<String> arrayList = myFilter(strArray, s -> s.split(",")[0].length() > 2, s -> Integer.parseInt(s.split(",")[1]) > 33);
        for (String s : arrayList) {
            System.out.println(s);
        }
    }

    private static ArrayList<String> myFilter(String[] strArray, Predicate<String> p1, Predicate<String> p2) {
        ArrayList<String> arrayList = new ArrayList<String>();

        for (String s : strArray) {
            boolean test = p1.and(p2).test(s);
            if (test) {
                arrayList.add(s);
            }
        }

        return arrayList;
    }
}
